// https://umijs.org/config/
import { defineConfig } from 'umi';
import path from 'path';
import proxy from './proxy';
import routes from './routes';

const { REACT_APP_ENV } = process.env;

export default defineConfig({
    // base: '/docs/',
    alias: {
        '@public': path.resolve(__dirname, '../public/'),
    },
    hash: true,
    antd: {},
    dva: {
        hmr: true,
    },
    dynamicImport: {
        loading: '@ant-design/pro-layout/es/PageLoading',
    },
    targets: {
        ie: 11,
    },
    locale: {
        default: 'zh-CN',
        antd: true,
    },
    // umi routes: https://umijs.org/docs/routing
    routes,
    access: {},
    // Theme for antd: https://ant.design/docs/react/customize-theme-cn
    theme: {
        // 如果不想要 configProvide 动态设置主题需要把这个设置为 default
        // 只有设置为 variable， 才能使用 configProvide 动态设置主色调
        // https://ant.design/docs/react/customize-theme-variable-cn
        'root-entry-name': 'variable',
    },
    // esbuild is father build tools
    // https://umijs.org/plugins/plugin-esbuild
    esbuild: {},
    title: false,
    ignoreMomentLocale: true,
    proxy: proxy[REACT_APP_ENV || 'dev'],
    manifest: {
        basePath: '/',
    },
    // Fast Refresh 热更新
    fastRefresh: {},
    nodeModulesTransform: { type: 'none' },
    mfsu: {},
    webpack5: {},
    exportStatic: {},
    qiankun: {
        master: {
            // 注册子应用信息
            apps: [
                {
                    name: 'dashboard', // 唯一 id
                    entry: '//localhost:8004', // html entry
                },
            ],
        },
    },
    mountElementId: 'root',
});
